#include <stdio.h>  
#include <sys/types.h>  
#include <unistd.h>  
#include <sys/wait.h>  
#include "Include/student_pub.h"  
#include "Include/course_pub.h"  
#include "Include/log_pub.h"  
#include <stdlib.h>  


void changestudent(){
    int choice;
    printf("1.修改全部\n2.修改姓名\n3.修改id\n0.返回");
    scanf("%d",&choice);
    if(choice == 1){
        revise_Student();
    }else if(choice == 2){
        name_Revise_Student();
    }else if(choice == 3){
        id_Revise_Student();
    }else if(choice == 0){
        return;
    }else{
        printf("无效输入");
        return;
    }
    return;
}

void student_main(){    
    int choice;    
    do {    
        printf("学生管理系统\n");    
        printf("1. 添加学生\n");    
        printf("2. 导入学生\n");    
        printf("3. 删除学生\n");    
        printf("4. 查看学生\n");    
        printf("5. 通过ID查看学生\n");    
        printf("6. 通过姓名查看学生\n");    
        printf("7. 修改学生信息\n");       
        printf("0. 退出\n");    
        printf("请输入您的选择: ");    
        scanf("%d", &choice);    
  
        switch (choice) {    
            case 1: add_Student(); break;    
            case 2: add_Student_import(); break;    
            case 3: delecte_Student(); break;
            case 4: view_Student(); break;    
            case 5: id_View_Student(); break;    
            case 6: name_view_Student(); break;    
            case 7: changestudent(); break;    
            case 0: printf("正在退出...\n"); break;    
            default: printf("无效选择！\n");    
        }    
    } while (choice != 0);    
}  
  
void class_main(){    
    int choice;    
    do {    
        printf("\n课程管理系统\n");    
        printf("1. 添加课程\n");    
        printf("2. 删除课程\n");    
        printf("3. 查看课程\n");    
        printf("4. 修改课程\n");    
        printf("0. 退出\n");    
        printf("请输入您的选择: ");    
        scanf("%d", &choice);    
  
        switch (choice) {    
            case 1: add_course(); break;    
            case 2: delete_course(); break;    
            case 3: view_course(); break;    
            case 4: revise_course(); break;    
            case 0: printf("正在退出...\n"); break;    
            default: printf("无效选择！\n");    
        }    
    } while (choice != 0);    
}  
  
// 程序主进程  
int main()  
{  
    int a = 0;  
    while (1)  
    {  
        printf("\n请输入要进入的模块:\n1): 课程管理模块\n2): 学生信息管理模块\n3): 退出\n");  
        scanf("%d", &a);  
        if (a == 1)  
        {  
            // printf("\n课程管理模块\n"); // 这行已被注释掉，因为上面的printf已经包含了这部分信息  
            class_main();  
        }  
        else if (a == 2)  
        {  
            student_main();  
        }  
        else if (a == 3)  
        {  
            break;  
        }  
        else  
        {  
            printf("\n请输入正确内容\n");  
        }  
    }  
    return 0;  
}